package com.jin.bean;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.jin.service.AddGroup;
import com.jin.service.UpdateGroup;
import com.jin.utils.StrictIntegerDeserializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;
/**
 * Created on 2025/4/27.
 * @description 用户实体类
 * @author Zhongyuan Jin
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "user")
@ToString
public class User {
    @NotNull(message = "用户ID不能为空", groups = UpdateGroup.class)
    @Null(message = "新增时ID必须为空", groups = AddGroup.class)
    @JsonDeserialize(using = StrictIntegerDeserializer.class) // 严格整数反序列化
    @TableId(type = IdType.AUTO)
    private Integer id;
    @NotBlank(message = "用户名不能为空", groups = AddGroup.class)
    private String username;// 用户名
    @NotBlank(message = "密码不能为空", groups = AddGroup.class)
    private String password;// 密码
    @JsonProperty("isAdmin")
    private boolean isAdmin;//  是否是管理员
    @JsonDeserialize(using = StrictIntegerDeserializer.class)
    private Integer unitId; // 所属单位的ID
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date registerTime; // 注册时间
    private Boolean isEnable;//  标识是否启用该用户，0为禁用，1为启用
}

